<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在线商城后台管理</title>
<link rel="stylesheet" type="text/css" href="views/admin/style/css/basic.css" />
<link rel="stylesheet" type="text/css" href="views/admin/style/css/manager.css" />
<link rel="stylesheet" type="text/css" href="views/admin/style/css/pagination.css" />
<script type="text/javascript" src="views/common/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="views/common/js/artDialog4.1.6/jquery.artDialog.js?skin=idialog"></script>
<script type="text/javascript" src="views/common/js/artDialog4.1.6/plugins/iframeTools.js"></script>
<script type="text/javascript" src="views/common/js/jquery-validation/jquery.validate.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
    $("tbody>tr>td").dblclick(function() {
        var tdVal = $(this).html();
        var tdName = $(this).attr("name");
        var id = $(this).parents("tr").find("td:first-child span").text();
        if(tdName != undefined){
            $(this).html("<input id='update" + id + "' type='text' name='" + tdName + "' value='" + tdVal + "'/>");
            $("#update" + id).focus().live("blur",function(){
                var updateVal = $(this).val();
                var content = $("#table").serialize();
                $.post("?c=manage&m=ajaxUpdate&id=" + id, content,
                    function(msg){
                        if(msg == 'success'){
                            $("#update" + id).parents("td").html(updateVal);
                        }else{
                         $.msgbox({type:'error',
                          msg:'更新失败！',
                          end:function(){
                                //location.reload();
		                      }
                         });
                        }
                    }
                );
            });
        }
    });
    
    $(".button").click(function(){
        var checkedLength = $("tbody tr.checked").length;
        if(checkedLength == 0){
            art.dialog.alert('请选中您要删除的记录！');
        }else{
            art.dialog.confirm('你确定要删除这'+ checkedLength +'条记录吗？',function() {});
            $("tbody tr.checked").each(function(){
                alert($(this).find("td:first-child span").text());
            });
        }
        //alert($("table tr.checked td:eq(0)").text());
    });
})
</script>
<script type="text/javascript">
    $(document).ready(function() {
        $(".del").click(function() {
            var id = $(this).parents("tr").find("td:eq(1)").text();
            art.dialog.confirm('你确定要删除这个管理员吗？', function () {
                $.get("?c=manager&m=del&id=" + id,
                    function(msg){
                        if(msg == 'success'){
                            art.dialog.tips('删除成功！', 1.5);
                            setTimeout(function(){
                                art.dialog.top.document.location.reload();
                            },1500);
                        } else {
                            art.dialog.tips('删除失败！', 1.5);
                        }
                    }
                );
            });
        })
    $(".update").click(function() {
        var id = $(this).parents("tr").find("td:eq(1)").text();
        art.dialog.open('?c=manager&m=update&id=' + id,{
            id:"iframe_update",
            title:'修改管理员',
            width:'500px',
            height:'230px'
        }).lock();
    });
    $("#add_manager").click(function() {
        art.dialog.open('?c=manager&m=add',{
            id:"iframe_add_manager",
            title:'新增管理员',
            width:'500px',
            height:'230px'
        }).lock();
    });  
})
</script>
<script type="text/javascript">
function pagination(page){
    location.href= '?c=manage&page=' + page;
// $.get("?c=manage&page=" + page, function(data){
//     alert("Data Loaded: " + data);
// });
}
</script>
<h2><a href="javascript:void(0)" id="add_manager">添加管理员</a>系统 -- 管理员列表</h2>

<div id="list">
    <form id="table">
	<table>
        <thead>
		<tr>
            <th width="10px"><input type="checkbox"/></th>
            <th>编号</th>
            <th>用户名</th>
            <th>邮箱</th>
            <th>等级</th>
            <th>注册时间</th>
            <th>登陆次数</th>
            <th>上次登录ip</th>
            <th>上次登录时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <{foreach from=$allManage key=key item=value}>
		<tr>
            <td><input type="checkbox"/></span></td>
            <td class="id"><{$value->id}></td>
            <td><{$value->user}></td>
            <td name="email"><{$value->email}></td>
            <td><{$value->level_name}></td>
            <td><{$value->reg_time|date_format:'%Y-%m-%d %H:%M:%S'}></td>
            <td><{$value->login_count}></td>
            <td><{$value->last_login_ip}></td>
            <td><{$value->last_login_time|date_format:'%Y-%m-%d %H:%M:%S'}></td>
            <td><a href="javascript:void(0)" class="update"><img src="views/admin/style/images/edit.gif" alt="编辑" title="编辑" /></a>
            <a href="javascript:void(0)" class="del"><img src="views/admin/style/images/drop.gif" alt="删除" title="删除" />
            </a>
            </td>
        </tr>
        <{foreachelse}>
            <tr><td colspan="10">暂无数据！</td></tr>
        <{/foreach}>
        </tbody>
        <tfoot>
        <tr class="action">
            <td>
            <a href="#" class="button danger">删&nbsp;除</a>
            </td>
            <td colspan="9">
                <div class="pagination pagination-right">
                <{$pagination}>
                </div>
            </td>
        </tr>
        </tfoot>
	</table>
    </form>
</div>
</body>
</html>